# SPDX-License-Identifier: GPL-2.0-or-later

# Makefile to compile flasher stub program
# Copyright (C) 2023 Espressif Systems Ltd.

# Prefix for ESP32-S3 cross compilers (can include a directory path)
CROSS ?= xtensa-esp32s3-elf-

# Path to the esp-idf root dir
IDF_PATH ?= ../..

STUB_ARCH := xtensa
STUB_CHIP_PATH := $(shell pwd)
STUB_COMMON_PATH := $(STUB_CHIP_PATH)/..
STUB_CHIP_ARCH_PATH := $(STUB_COMMON_PATH)/$(STUB_ARCH)
STUB_OBJ_DEPS := sdkconfig.h
STUB_LD_SCRIPT := stub.ld
STUB_CHIP := ESP32S3

SRCS := $(IDF_PATH)/components/app_trace/port/$(STUB_ARCH)/port.c \
	$(IDF_PATH)/components/xtensa/eri.c \
	$(IDF_PATH)/components/esp_hw_support/port/esp32s3/rtc_clk.c \
	$(IDF_PATH)/components/esp_hw_support/port/esp32s3/rtc_clk_init.c \
	$(IDF_PATH)/components/esp_hw_support/port/esp32s3/rtc_time.c

CFLAGS := -std=gnu99 -mlongcalls -mtext-section-literals

INCLUDES := -I$(IDF_PATH)/components/esp32s3/include -I$(IDF_PATH)/components/soc/esp32s3/include \
	-I$(IDF_PATH)/components/esp_rom/include/esp32s3 -I$(IDF_PATH)/components/xtensa/esp32s3/include \
	-I$(IDF_PATH)/components/hal/esp32s3/include \
	-I$(IDF_PATH)/components/esp_hw_support/port/esp32s3/private_include \
	-I$(IDF_PATH)/components/esp_hw_support/port/esp32s3

DEFINES :=

LDFLAGS := -L$(IDF_PATH)/components/esp32s3/ld -T$(IDF_PATH)/components/esp_rom/esp32s3/ld/esp32s3.rom.ld \
	-T$(IDF_PATH)/components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld

include ../stub_common.mk
